<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var car = {
            carname: 'wuling',
            carprice: 50000,
            carcolor: 'red',
            carweight: '850kg',

            start: function () {
                console.log('车启动了！')
            },
            stop: function () {
                console.log('车停止了！')
            }
        }

        // console.log(car)
        //拿到对象的所有key属性
        //for in

        // for (var key in car) {
        //     console.log('key', key)
        //     console.log(car[key])
        // }

        console.log(Object.keys(car))
        if (Object.keys(car).lenght) {

        }

        for (var i = 0; i < Object.keys(car).length; i++) {
            // console.log('key',Object.keys(car)[i])
            // console.log('value',car[Object.keys(car)[i]])
        }

        console.log(Object.values(car))


        //按引用传递

        var obj1 = {
            name: 'tom'
        }

        //对象拷贝
        var objNew = Object.assign({}, obj1)

        obj1.name = 'mick'

        console.log('obj1', obj1)
        console.log('objNew', objNew)

        var obj2 = {
            age: 10
        }

        console.log(Object.assign(obj1, obj2, {
            height: 170
        }, {
            parent: 'bob'
        }))
    </script>
</body>

</html>